<!--
จำเป็นต้องมีสำหรับ หน้า print
div => "head" ถูกแสดงด้านบนทุกหน้า
thead => "tableHead" หัวตารางที่จะถูกแสดงทุกหน้า
2 => "" หัวตารางที่จะถูกแสดงทุกหน้า
tr => "row[no]" แถวในตาราง, class => "row"
td => class => "rowTd" ใช้หาความสูงแดวตารางใน IE
tr => "emptyRow" แถวว่างท้ายตาราง
4 => "foot" แสดงที่ส่วนท้ายทุกหน้า
-->
<div id="divFirstHeader"></div>  <div class="header">
    <div class="title"><?php echo $this->element('print/title'); ?></div>
    <div class="documentTitle">
        <div class="documentNote">DELIVERY REQUEST NOTE</div>
        <table class="documentNo" style="font-size: 130%;">
            <tr>
                <td colspan="2"><label>Request no.</label></td>
            </tr>
            <tr>
                <td width="40px">&nbsp;</td>
                <td style="vertical-align: middle;"><?php echo $this->data['DeRH']['request_no']; ?></td>
            </tr>
            <tr>
                <td colspan="2"><label>Request Status</label></td>
            </tr>
            <tr>
                <td width="40px">&nbsp;</td>
                <td><?php echo $this->data['DeRStatus']['title']; ?></td>
            </tr>
        </table>
        <table>
            <tr>
                <td width="90px"><label>Request date</label></td>
                <td><?php echo $this->data['DeRH']['request_date']; ?></td>
                <td><label>Page</label></td>
                <td><span class="pageNo">1/1</span></td>
            </tr>
            <tr>
                <td><label>Request by</label></td>
                <td colspan="3"><?php echo $this->data['DeRH']['request_by']; ?></td>
            </tr>
<!--            <tr>
                <td><label>Customer no.</label></td>
                <td colspan="3"><?php echo $this->data['Customer']['cust_no']; ?></td>
            </tr>-->
            <tr>
                <td><label>Customer Name</label></td>
                <td colspan="3"><?php echo $this->data['Customer']['name']; ?></td>
            </tr>
<!--            <tr>
                <td><label>Site no.</label></td>
                <td colspan="3"><?php echo $this->data['Site']['site_no']; ?></td>
            </tr>-->
            <tr>
                <td><label>Site Name</label></td>
                <td colspan="3"><?php echo $this->data['Site']['name']; ?></td>
            </tr>
            <tr>
                <td><label>End User</label></td>
                <td colspan="3"><?php echo $this->data['DeRH']['end_user']; ?></td>
            </tr>
            <tr>
                <td><label>Customer Document no.</label></td>
                <td colspan="3"><?php echo $this->data['DeRH']['customer_document_no']; ?></td>
            </tr>
        </table>
    </div>
    <table>
        <tr>
            <td width="120px"><label>Vendor no.</label></td>
            <td width="250px">
                <?php echo $this->data['Supplier']['code']; ?>
            </td>
        </tr>
        <tr>
            <td><label>Vendor Name</label></td>
            <td>
                <?php echo $this->data['Supplier']['name']; ?>
            </td>
        </tr>
        <tr>
            <td><label>Request Delivery Date</label></td>
            <td>
                <?php echo $this->data['DeRH']['due_date']; ?>
            </td>
        </tr>
        <tr>
            <td><label>Actual Delivery Date</label></td>
            <td>
                <?php echo empty($this->data['DeRH']['supplier_due_date']) ? '-' : $this->data['DeRH']['supplier_due_date']; ?>
            </td>
        </tr>
    </table>
    <br />&nbsp;
</div>
<br />
<div class="main">
    <table id="dataTable" class="dataTable" cellspacing="0" cellpadding="0" >
        <thead id="tableHead">
            <tr align="center">
                <th width="30px">Item<br>ลำดับ</th>
                <th width="100px">Part Number<br>รหัสสินค้า</th>
                <th width="90px">Stock Code</th>
                <th>Description<br>รายการ</th>
                <th width="60px">
                    Qty<?php echo $this->data['DeRH']['is_partial'] ? '*' : ''; ?><br>
                    จำนวน
                </th>
                <th width="45px">Unit<br>หน่วย</th>
                <th width="65px">Price/Unit<br>ราคา/หน่วย</th>
                <th width="60px">Amount<br>จำนวนเงิน</th>
            </tr>
        </thead>
        <tbody id="tableBody">
            <?php
            $i = 0;
            $sumQty = 0;
            $total = 0;
            foreach ($this->data['DeR'] as $data) :
                ?>
                <tr id="row<?php echo $i; ?>" class="row">
                    <td class="center rowTd"><?php echo $i + 1; ?></td>
                    <td><?php echo $data['Product']['supplier_part_no']; ?></td>
                    <td><?php echo $data['CustProductSite']['stock_code']; ?></td>
                    <td><?php echo!empty($data['CustProductSite']['text']) ? $data['CustProductSite']['text'] : $data['Product']['text']; ?></td>
                    <td class="text-right">
                        <?php
                        $qty = $data['request_qty'];
                        if ($this->data['DeRH']['is_partial']) {
                            $qty = $data['receive_qty'];
                            echo $data['receive_qty'] . ' / ';
                        }
                        echo $data['request_qty'];
                        if ($this->data['DeRH']['delivery_request_status_id'] >= DeRStatus::RECEIVED) {
                            
                        }
                        $sumQty += $qty;
                        ?>
                    </td>
                    <td class="center"><?php echo $data['Product']['Unit']['title']; ?></td>
                    <td class="text-right"><?php echo number_format($data['price'], 2); ?></td>
                    <td class="text-right">
                        <?php
                        $amount = $data['price'] * $qty;
                        $total += $amount;
                        echo number_format($amount, 2);
                        ?>
                    </td>
                </tr>
                <?php ++$i;
            endforeach; ?>
            <?php for ($i = 0; $i < 20; ++$i) : ?>
                <tr class="emptyRow" style="height: 50px"> <!-- สร้างแถวเปล่าขึ้นมาเพื่อยืดขนาดตารางให้เต็มหน้า-->
                    <td class="rowTd">&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
                </tr>
            <?php endfor; ?>
        </tbody>
        <tfoot>
            <tr class="text-right"> <!-- สร้างแถวเปล่าขึ้นมาเพื่อยืดขนาดตารางให้เต็มหน้า-->
                <td class="rowTd" colspan="4">รวม</td>
                <td><?php echo $sumQty; ?></td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td><?php echo number_format($total, 2); ?></td>
            </tr>
        </tfoot>
    </table>
</div>
<div class="footer" style="height: 300px;">
    <div class="left">
        <div class="remark" style="width: 270px">
            <label>Customer Remark</label><br />
            <?php echo empty($this->data['DeRH']['customer_comment']) ? '-' : $this->data['DeRH']['customer_comment']; ?><br />
            <label>Vendor Remark</label><br />
            <?php echo empty($this->data['DeRH']['supplier_comment']) ? '-' : $this->data['DeRH']['supplier_comment']; ?>
        </div>
        <?php if ($this->data['DeRH']['is_partial']) { ?>
            <div class="caption">* จำนวน Received / Request </div>
        <?php } ?>
    </div>
    <table class="right">
        <tr>
            <td>
                <div class="custSignature" style="padding-left: 0px">
                    <hr />
                    <span>Customer/Date</span>
                </div>
            </td>
            <td>
                <div class="custSignature" style="padding-left: 0px">
                    <hr />
                    <span>Vendor/Date</span>
                </div>
            </td>
        </tr>
    </table>
</div>
